<?php
/**
 *
 * @author Strawberry🍓
 * @date 2021-05-24 4:33 下午
 *
 */

namespace app\admin\controller;


use app\admin\model\AdminUser;
use app\common\controller\AdminBaseController;
use app\common\model\tang\FloorConfig as FloorConfigModel;
use app\common\model\tang\CostType;

use app\common\model\tang\ReleaseUser;
use think\facade\Db;

class FloorConfig extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->model = new FloorConfigModel();
    }
    //首页
    public function index()
    {
        if (IS_AJAX) {
            return $this->model->getAdminPageData($this->param, 'id desc',[]);
        }
        return $this->fetch();
    }

    /**
     * @return mixed|string|\think\response\Json
     * @throws \think\db\exception\DbException
     * @author: Hhy <jackhhy520@qq.com>
     * @date: 2020/6/30 0030
     * @describe:添加编辑
     */
    public function add()
    {
        if (IS_AJAX) {
            $data = $this->request->post();
            return $this->model->doAll($data);
        }
        $id = $this->request->param("id/d");//父id
        $info = $this->model->find($id);

        $management = (new ReleaseUser())->where('groups','<>',4)->select();
        //获取菜单列表
        $this->assign(compact("info", "id","management"));
        return $this->fetch();
    }
    /**
     * 删除
     */
    public function del()
    {
        $param = $this->request->param('ids');
        $del =  $this->model->del($param);
        if($del){
            return self::ajaxResult([],0,1,'删除成功');
        }else{
            return self::ajaxResult([],0,-1,'删除失败');
        }
    }
}